with v8.Class_Value;
with Ada.Calendar;
package v8.Class_Date is
   type Date (<>) is new v8.Class_Value.Value with private;
   type Pointer is access all Date;
   -- An instance of the built-in Date constructor (ECMA-262, 15.9).


   function Create (time : double) return Pointer;
   -- represents the number of milliseconds in  Universal Coordinated Time
   -- between the specified date and midnight January 1, 1970.

   function Number_Value (this : Date) return double;
   -- A specialization of Value::NumberValue that is more efficient
   -- because we know the structure of this object.

   procedure Date_Time_Configuration_Change_Notification;
   -- Notification that the embedder has changed the time zone,
   -- daylight savings time, or other date / time configuration
   -- parameters.  V8 keeps a cache of various values used for
   -- date / time computation.  This notification will reset
   -- those cached values for the current context so that date /
   -- time configuration changes would be reflected in the Date
   -- object.
   --
   -- This API should not be called more than needed as it will
   -- negatively impact the performance of date operations.

   function Cast is new Ada.Unchecked_Conversion (v8.Class_Value.Pointer, Pointer);
   -- Convert Value to Date


   -- [TODO] provide routines interact with Ada.Calendar.Time

   function To_Ada (this : Date) return Ada.Calendar.Time;
   -- covnert js time to ada UTC time

   function To_JS (time : Ada.Calendar.Time) return Pointer;
   -- convert ada UTC time to js time

private
   type Date is new v8.Class_Value.Value with null record;

   pragma Import (CPP, Create, "_ZN2v84Date3NewEd");
   pragma Import (CPP, Number_Value, "_ZNK2v84Date11NumberValueEv");
   pragma Import (CPP, Date_Time_Configuration_Change_Notification, "_ZN2v84Date39DateTimeConfigurationChangeNotificationEv");
end v8.Class_Date;
